package com.tudou.player
{
	import com.aspirin.frameworks.modulesConnector.core.ModulesMediator;
	import com.aspirin.frameworks.modulesConnector.interfaces.IModulesMediator;
	import com.tudou.player.videoPlayerModule.VideoPlayerCommands;
	import com.tudou.player.videoPlayerModule.VideoPlayerModule;
	
	public class PlayerModulesMediator extends ModulesMediator
	{
		protected static var instance : IModulesMediator;
		
		public function PlayerModulesMediator()
		{
			if ( instance != null ) throw Error(SINGLETON_MSG);
			instance = this;
			
			initialize();	
			
		}
		
		protected function initialize() : void
		{
			super.initializeMediator();
			
			registerModules();
			
			start();
		}
		
		protected function registerModules() : void
		{
			registerModule( new VideoPlayerModule() );
		}
		
		public static function getInstance() : IModulesMediator
		{
			if (instance == null) instance = new PlayerModulesMediator();
			return instance;
		}
		
		//-----------------------------------------------------------------------------------------
		private function start() : void
		{
			broadcastCommand( VideoPlayerCommands.PLAY, null, VideoPlayerCommands.TYPE );
		}
		
	}
}